package com.siwei.mes.entity.system;

import cn.dev33.satoken.stp.StpUtil;
import com.siwei.mes.common.validator.AddGroup;
import com.siwei.mes.common.validator.UpdateGroup;
import com.siwei.mes.common.validator.bus.SyncGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

/**
 * @program: mes-platform
 * @description:
 * @author: yangke
 * @create: 2023-12-17 15:50
 **/
@Data
@Table(name = "pk_project_area")
@ApiModel(value = "ProjectArea", description = "工程区域划分表")
@Accessors(chain = true)
public class ProjectArea implements Serializable {
    private static final long serialVersionUID = 984632670482066159L;

    /**
     * 主键id
     */
    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "主键id", name = "id")
    private Long id;

    /**
     * 工程区域名称
     */
    @Column(name = "project_area")
    @ApiModelProperty(value = "工程区域名称", name = "projectArea")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class, SyncGroup.class}, message = "工程区域名称为空")
    private String projectArea;

    /**
     * 区域组长ID
     */
    @Column(name = "headman_id")
    @ApiModelProperty(value = "区域组长ID", name = "headmanId")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class, SyncGroup.class}, message = "区域组长ID为空")
    private String headmanId;

    /**
     * 区域组长名称
     */
    @Column(name = "headman_name")
    @ApiModelProperty(value = "区域组长名称", name = "headmanName")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class, SyncGroup.class}, message = "区域组长名称为空")
    private String headmanName;

    /**
     * 客服员ID
     */
    @Column(name = "customer_service_id")
    @ApiModelProperty(value = "客服员ID", name = "customerServiceId")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class, SyncGroup.class}, message = "客服员ID为空")
    private String customerServiceId;

    /**
     * 客服员名称
     */
    @Column(name = "customer_service_name")
    @ApiModelProperty(value = "客服员名称", name = "customerServiceName")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class, SyncGroup.class}, message = "客服员名称为空")
    private String customerServiceName;

    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除", name = "isDel")
    private Integer isDel;

    public ProjectArea init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                .setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                    .setCreateTime(new Date())
                    .setIsDel(0);
        }
        return this;
    }
}
